import { Text, useMessage } from 'alemonjs'
import { validate, selects } from '@src/apps/index'
import {
  qidToUid,
  loadPlayerAttributes,
  loadEnemyAttributes,
  battleInitialization,
  makeEnemy
} from '@src/apps/tools'
export const regular = /^(!|！|\/)?测试/
const response = onResponse(selects, async e => {
  const [message] = useMessage(e)
  // 读取玩家属性
  const userId = await qidToUid(e.UserId || e.UserKey)
  const playerAttr = await loadPlayerAttributes(userId)
  // 读取敌人属性
  const enemyList = [
    {
      name: '测试敌人[龙族]',
      race_name: '龙',
      level: 1,
      affixes: [],
      equipped: {}
    }
  ]
  const enemyAttr = await loadEnemyAttributes(enemyList)
  // 战斗初始化
  await battleInitialization(playerAttr, enemyAttr, '普通战斗')

  setTimeout(() => {
    message.send(format(Text('\n【战斗加载完成】\n发送[战斗面板]查看战斗详情')))
  }, 1000)

  return
})
export default onResponse(selects, [validate, response.current])
